import axios from 'axios'
import http from '../../ajax/http'
const state = {
    tableState:[] 
}
// const actions = {
//     ljnGetData({commit}){
//         return http({
//             method:'get',
//             url:'/mock/24/getGoodsData'
//         }).then(res =>{
//             commit('ljnDatamutations',res.data.data)
//             return res.data.data
//             // console.log(res.data.data);
//         })
//     }
// }
const actions = { //通过上下文的commit触发mutations
    async ljnGetData({ commit }) {
        //异步操作
        const res = await axios({
            url: '/mock/24/getGoodsData',
            method: 'get'
        });
        // console.log(res.data.data)
        commit('ljnDatamutations', res.data.data);
        return res.data.data;
    }
}
const mutations = {
    ljnDatamutations(state,data){
        state.tableState = data
    }
}
const getters = {
    
}
export default {
    state,
    actions,
    mutations,
    getters,
    beforeCreate() {
        axios({
            url: '/mock/24/getGoodsData',
        }).then(res=>{
            console.log(res.data.data)
            this.myarr = res.data.data
        })
    },
    
}





